package com.adxnz.vertx;

import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.ext.web.Router;

/**
 * Run Vert.x-Web
 * 
 * @author worley
 */
public class App {

    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();
        HttpServer server = vertx.createHttpServer();
        Router router = Router.router(vertx);
        router.route().handler(ctx -> {
            // 所有请求都会调用这个处理器
            HttpServerResponse response = ctx.response();
            response.putHeader("content-type", "text/plain");
            // 写响应结束请求
            response.end("Hello World from Vert.x-Web!");
        });

        server.requestHandler(router).listen(8080);
        
        System.out.println("Vert.x-Web Started!");
    }
}
